package com.hw.protocol.tool.decode.hw;

import com.hw.protocol.tool.model.entity.hw.AbsFlowMeter;
import com.hw.protocol.tool.model.entity.hw.Dtu38;

/**
 * @author : lihy
 * @date : 2023/3/23 14:41
 * description: 流量计(38898/38899)实时数据解码器
 */

public class Dtu38Decode extends FlowMeterDecodeTemplate {

    private Dtu38 fm;

    Dtu38Decode(AbsFlowMeter fm, byte[] data) {
        super(fm, data);
        this.fm = (Dtu38)fm;
    }

    @Override
    void setVolume() {
        fm.setVolume(dataBuf.readUnsignedIntLE());
    }

    @Override
    void setRealVolume() {
        fm.setRealVolume(dataBuf.readUnsignedIntLE());
    }

    @Override
    void setReverseVolume() {
        fm.setReverseVolume(dataBuf.readUnsignedIntLE());
    }

    @Override
    void setExternalPress() {
        fm.setExternalPress1(dataBuf.readFloatLE());
        fm.setExternalPress2(dataBuf.readFloatLE());
    }

    @Override
    boolean dtu38() {
        return true;
    }
}
